package com.example.springbootproject.mianshi.singleton;

/**
 * Singleton05 的改进版
 * 即 双重检查单例模式
 */
public class Singleton05_1 {

    private static Singleton05_1 INSTANCE;

    public static Singleton05_1 getInstance() throws InterruptedException {
        if(INSTANCE == null){
            synchronized (Singleton05_1.class){
                if (INSTANCE == null){
                    Thread.sleep(1000);
                    INSTANCE = new Singleton05_1();
                }

            }
        }
        return INSTANCE;
    }

    private Singleton05_1(){

    }

}
